<p>When either the equality operator in a null test or the logical operator that follows it is reversed, the code has the appearance of safely
null-testing the object before dereferencing it. Unfortunately the effect is just the opposite - the object is null-tested and then dereferenced
<em>only</em> if it is null, leading to a guaranteed null pointer dereference.</p>
<h2>Noncompliant Code Example</h2>
<pre>
if (str == null &amp;&amp; str.length() == 0) {
  System.out.println("String is empty");
}

if (str != null || str.length() &gt; 0) {
  System.out.println("String is not empty");
}
</pre>
<h2>Compliant Solution</h2>
<pre>
if (str == null || str.length() == 0) {
  System.out.println("String is empty");
}

if (str != null &amp;&amp; str.length() &gt; 0) {
  System.out.println("String is not empty");
}
</pre>
<h2>Deprecated</h2>
<p>This rule is deprecated; use {rule:java:S2259} instead.</p>

